<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- richtext.qdoc -->
  <title>Advanced Rich Text Processing | Qt GUI 5.14.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtgui-index.html">Qt GUI</a></td><td >Advanced Rich Text Processing</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtgui-index.html">Qt 5.14.2 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="richtext-common-tasks.html" />
  <link rel="next" href="richtext-html-subset.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="richtext-common-tasks.html">Common Rich Text Editing Tasks</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="richtext-html-subset.html">Supported HTML Subset</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#handling-large-files">Handling Large Files</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Advanced Rich Text Processing</h1>
<span class="subtitle"></span>
<!-- $$$richtext-advanced-processing.html-description -->
<div class="descr"> <a name="details"></a>
<a name="handling-large-files"></a>
<h2 id="handling-large-files">Handling Large Files</h2>
<p>Qt does not limit the size of files that are used for text processing. In most cases, this will not present a problem. For especially large files, however, you might experience that your application will become unresponsive or that you will run out of memory. The size of the files you can load depends on your hardware and on Qt's and your own application's implementation.</p>
<p>If you are faced with this problem, we recommend that you address the following issues:</p>
<ul>
<li>You should consider breaking up large paragraphs into smaller ones as Qt handles small paragraphs better. You could also insert line breaks at regular intervals, which will look the same as one large paragraph in a <a href="../qtwidgets/qtextedit.html">QTextEdit</a>.</li>
<li>You can reduce the amount of blocks in a <a href="qtextdocument.html">QTextDocument</a> with <a href="qtextdocument.html#maximumBlockCount-prop">maximumBlockCount()</a>. The document is only as large as the number of blocks as far as <a href="../qtwidgets/qtextedit.html">QTextEdit</a> is concerned.</li>
<li>When adding text to a text edit, it is an advantage to add it in an edit block (see example below). The result is that the text edit does not need to build the entire document structure at once.</li>
</ul>
<p>We give an example of the latter technique from the list. We assume that the text edit is visible.</p>
<pre class="cpp">

  textEdit<span class="operator">.</span>show();

  textCursor<span class="operator">.</span>beginEditBlock();

  <span class="keyword">for</span> (<span class="type">int</span> i <span class="operator">=</span> <span class="number">0</span>; i <span class="operator">&lt;</span> <span class="number">1000</span>; <span class="operator">+</span><span class="operator">+</span>i) {
      textCursor<span class="operator">.</span>insertBlock();
      textCursor<span class="operator">.</span>insertText(paragraphText<span class="operator">.</span>at(i));
  }

  textCursor<span class="operator">.</span>endEditBlock();

</pre>
</div>
<!-- @@@richtext-advanced-processing.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="richtext-common-tasks.html">Common Rich Text Editing Tasks</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="richtext-html-subset.html">Supported HTML Subset</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
